// store/modules/scene.js
const state = {
  selectedScenes: [], // 保存用户选择的场景
  currentScene: null, // 当前使用的场景
  interviewer: null, // 选择的面试官
  interviewMode: null,
  interviewCount: 3,
}

const mutations = {
  SET_SELECTED_SCENES(state, scenes) {
    state.selectedScenes = scenes
  },
  SET_CURRENT_SCENE(state, scene) {
    state.currentScene = scene
  },
  SET_INTERVIEWER(state, interviewer) {
    state.interviewer = interviewer
  },
  SET_INTERVIEW_MODE(state, mode) {
    state.interviewMode = mode
  },
  SET_INTERVIEW_COUNT(state, count) {
    state.interviewCount = count;
  },
}

const actions = {
  saveSelectedScenes({ commit }, scenes) {
    commit('SET_SELECTED_SCENES', scenes)
    // 如果没有当前场景，设置第一个为当前场景
    if (scenes.length > 0) {
      commit('SET_CURRENT_SCENE', scenes[0])
    }
  },
  changeCurrentScene({ commit }, scene) {
    commit('SET_CURRENT_SCENE', scene)
  },
  saveInterviewer({ commit }, interviewer) {
    commit('SET_INTERVIEWER', interviewer)
  },
  saveInterviewMode({ commit }, mode) {
    commit('SET_INTERVIEW_MODE', mode)
  },
  saveInterviewCount({ commit }, count) {
  commit('SET_INTERVIEW_COUNT', count);
  },
}

const getters = {
  getSelectedScenes: state => state.selectedScenes,
  getCurrentScene: state => state.currentScene,
  getInterviewer: state => state.interviewer,
  getInterviewMode: state => state.interviewMode,
   getInterviewCount(state) {
    return state.interviewCount;
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
